//引入webpack-merge插件进行合并
const {merge} = require('webpack-merge');
const {HomePath}=require('../tools.js');
//引入webpack.base.conf.js文件
const base = require('./webpak.base.conf.js');
//引入webpack
const webpack = require('webpack');
const config = global.au.config;
//进行合并，将webpack.base.conf.js中的配置合并到这
if(module.hot){
    module.hot.accept();
}
module.exports = merge(base, {
    devServer: {
        contentBase: HomePath("/devDist/service"),
        compress: true,//gzip
        writeToDisk:true,
        disableHostCheck: true,
        port: config.devServer.port,
        https:true,
        hot: true,
        hotOnly: true,
        publicPath:config.serviceHost+'/',
        public:config.serviceHost+'/',
        headers:{
            'Access-Control-Allow-Origin':'*',
            'Access-Control-Allow-Methods':'GET, POST, PUT, DELETE, OPTIONS',
            'Access-Control-Allow-Headers':'Content-Type',
        }
    },
    //模块参数
    mode: 'development',
    //启用source-map方便调试
    devtool: 'source-map',
    plugins: [
        //定义全局变量
        new webpack.DefinePlugin({
            //这里必须要解析成字符串进行判断，不然将会被识别为一个变量
            DEV: JSON.stringify('development')
        }),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.SourceMapDevToolPlugin(),
    ]
});
